import { ProtocolComponent } from "@components/Apps/InertialNavigation/InertialNavigationComponent";
import sensorData from "@components/Apps/Simulation/sensorModel/sensor";
import { ClientMessage } from "@runtime/generate/message/ClientMessage";
import MessageHandler from "@runtime/module/Handler/MessageHandler";

export default class DeviceDataAdapterUpdateMessageHandler extends MessageHandler<ClientMessage.DeviceDataAdapterUpdateMessage> {
    protected async RunAsync(message: ClientMessage.DeviceDataAdapterUpdateMessage): Promise<void> {
        console.log(message, '传感器消息返回值++++++++++++++++++++++++++++++++++');
        // const newData = JSON.parse(message.Content)
        // console.log(newData);
        if (message.Id == 11002) {
            sensorData.Default.imageData_twelve.value = message.Content
            console.log('sensorData.Default.imageData_twelve.value',sensorData.Default.imageData_twelve.value);
        } else if(message.Id == 11001) {
            sensorData.Default.imageData_six.value = message.Content
            console.log('sensorData.Default.imageData_six.value',sensorData.Default.imageData_six.value);
        }
        if (message.Id == 11005) {
            const newData = JSON.parse(message.Content)
            console.log(newData);
            
            sensorData.Default.lon.value = newData.Result.gnssBestPose.longitude.toFixed(5);//经度
            sensorData.Default.lat.value = newData.Result.gnssBestPose.latitude.toFixed(5);//纬度
            sensorData.Default.heading.value = newData.Result.heading.heading.toFixed(5);//航向角
            sensorData.Default.pitch.value = newData.Result.heading.pitch.toFixed(5);//俯仰角
            sensorData.Default.num_sats_tracked.value = newData.Result.gnssBestPose.num_sats_tracked;//卫星数量
            sensorData.Default.height_msl.value = newData.Result.gnssBestPose.height_msl.toFixed(2);//海拔
        }
    }
}